<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        .div {

            border:1px solid #000;
            /* line-height: 1ex; */
        }
        img{
            display: block;
            width:200px;
            height: 200px;
            /* vertical-align: bottom; */
        }
    </style>
</head>

<body>
    <h3>如何清除图片下方出现几像素空白间隙</h3>
    <div class="div">
        <img src="img/4.jpg" alt="">
    </div>
    <p>img是行级块元素，有默认的行高（line-height:(normal)1-1.2），含有默认的垂直对齐方式</p>
    <p>1.img设置vertical-align: bottom;</p>
    <p>2.父元素设置line-height: 1ex;</p>
    <p>3.img改成块级元素 display: block;</p>
</body>

</html>